import React, { Component } from 'react'
import './index.css'

export class TabControl extends Component {
  changeIndex (index) {
    this.props.changeClick(index);
  }
  render () {
    const { tabList, currentIndex } = this.props;
    return (
      <div className='tabsList'>
        {
          tabList.map((item, index) => {
            return <span key={item}
              className={index === currentIndex ? 'active' : ''}
              onClick={() => this.changeIndex(index)}>{item}</span>
          })
        }
      </div>
    )
  }
}

export default TabControl